package com.jprocms.module.cms.controller.admin.content.vo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.jprocms.module.cms.dal.dataobject.channel.ChannelDO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.ToString;

import java.util.List;
import java.util.stream.Collectors;

@Schema(description = "管理后台 - 内容引用来源 Response VO")
@Data
@ToString(callSuper = true)
public class ContentOriginVo {
    @Schema(description = "ID", required = true)
    private Long id;

    @Schema(description = "创建方式（1:直接创建    2:投稿  3:引用  4:复制   5  主动采集")
    private Integer createMode;

    @Schema(description = "站点ID")
    private Long siteId;

    @Schema(description = "来源站点")
    private String siteName;

    @Schema(description = "来源栏目ID", required = true)
    private Long channelId;

    @Schema(description = "来源栏目名称")
    private String channelName;

    @JsonIgnore
    @Schema(description = "父节点到自身")
    List<ChannelDO> nodeList;

    /**
     * 父节点到自身栏目名称
     *
     * @return
     */
    @Schema(description = "父节点到自身")
    public List<String> getNodeNames() {
        return getNodeList().stream().map(ChannelDO::getName).collect(Collectors.toList());
    }


}
